import sequtils

proc saddlePoints*(mat: seq[seq[int]]): seq[(int,int)] = 
  if mat.len == 0: return
  
  var colMin = newSeqWith(mat[0].len, int.low)

  for i, row in mat:
    let m = max(row)
    for j, x in row: 
      if x == m:
        if colMin[j] == int.low:
          colMin[j] = mat.mapIt(it[j]).min 
        if colMin[j] == x:
          result.add((i + 1, j + 1))
